﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Data.SqlClient;

namespace EnterAndQuit
{
    public class DbHelper
    {
        //连接数据库
        private static readonly string conString = "server=.;database=Admin3000;uid=sa;pwd=123456";

        //查询数据库
        public static DataTable GetData(string sql)
        {
            SqlDataAdapter adapter = new SqlDataAdapter(sql, conString);
            DataTable table = new DataTable();
            adapter.Fill(table);
            return table;
        }

        //更 删 改 数据库
        public static int AddOrUpdateOrDelete(string sql)
        {
            SqlConnection connection = new SqlConnection(conString);
            SqlCommand command = new SqlCommand(sql, connection);
            connection.Open();
            var X = command.ExecuteNonQuery();
            connection.Close();
            return X;
        }
    }
}